/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.draw2d;

import org.eclipse.draw2d.geometry.Point;


/**
 * A transparent figure intended to be added exclusively to a {@link LayeredPane}, who has
 * the responsibilty of managing its layers. 
 */
public class Layer
	extends Figure
{

/**
 * Overridden to implement transparent behavior.
 * @see IFigure#containsPoint_0(int, int)
 * 
 */
public boolean containsPoint_0(int x, int y) {
	if (isOpaque())
		return super.containsPoint_0(x, y);
	Point pt = new Point(x, y);
	translateFromParent(pt);
	for (int i = 0; i < getChildren().size(); i++) {
		IFigure child = (IFigure)getChildren().get(i);
		if (child.containsPoint_0(pt.x, pt.y))
			return true;
	}
	return false;
}

/**
 * Overridden to implement transparency.
 * @see IFigure#findFigureAt_2(int, int, TreeSearch)
 */
public IFigure findFigureAt_2(int x, int y, TreeSearch search) {
	if (!isEnabled())
		return null;
	if (isOpaque())
		return super.findFigureAt_2(x, y, search);

	IFigure f = super.findFigureAt_2(x, y, search);
	if (f == this)
		return null;
	return f;
}

}
